<!DOCTYPE html>
<html>
  <head>
    <!-- {% block head %} -->
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title>开发框架|蓝鲸智云企业版</title>
        <meta name="description" content=""/>
        <meta name="author" content=""/>
        <!-- <link rel="shortcut icon" href="{{ STATIC_URL }}/favicon.ico" type="image/x-icon"> -->
        <!-- bootstrap css -->
		    <link href="{{ STATIC_URL }}assets/bootstrap-3.3.4/css/bootstrap.min.css" rel="stylesheet">
		    <!-- 禁止bootstrap 响应式 （app根据自身需求启用或禁止bootstrap响应式） -->
        <link href="{{ STATIC_URL }}assets/bootstrap-3.3.4/css/bootstrap_noresponsive.css" rel="stylesheet">
		    <!--自定义css-->
		    <link href="{{ STATIC_URL }}css/bk.css?v={{ STATIC_VERSION }}" rel="stylesheet">
        <link href="{{ STATIC_URL }}css/index.css?v={{ STATIC_VERSION }}" rel="stylesheet">
        <!-- <script src="{{ STATIC_URL }}jquery/jquery.json-2.3.min.js"></script> -->
        <!-- 处理jquery兼容问题，jQuery Migrate（迁移）插件包含了1.6.4以来存在但1.9已不支持所有API -->
        <!-- <script src="{{ STATIC_URL }}assets/js/jquery-migrate-1.2.1.min.js"></script> -->
        <!-- bootstrap js  -->
        <script src="{{ STATIC_URL }}assets/bootstrap-3.3.4/js/bootstrap.min.js"></script>
        <!-- jquery ui js-->
        <!-- <script src="{{ STATIC_URL }}assets/jquery-ui-1.11.0.custom/jquery-ui.min.js"></script> -->
        <!-- 平台 js  -->
        <script src="{{ STATIC_URL }}assets/js/bk.js"></script>
   

        <!-- 这个是全局配置，如果需要在js中使用app_id和site_url,则这个javascript片段一定要保留 -->
        <script type="text/javascript">
            var app_code = "{{ APP_CODE }}";			// 在蓝鲸系统里面注册的"应用编码"
            var site_url = "{{ SITE_URL }}";			// app的url前缀,在ajax调用的时候，应该加上该前缀
            var remote_static_url = "{{ REMOTE_STATIC_URL }}";   //远程资源链接，403页面需要，不要删除
            var debug_mode = JSON.parse("{{ DEBUG }}");	// 是否调试模式
            var static_url = "{{ STATIC_URL }}"; // 静态资源前缀
        </script>
    <!-- {% endblock %} -->
  </head>
<div class="king-block king-block-bordered king-block-themed m20"><a href="{{ SITE_URL }}"><span>返回</span></a></div>
<div class="king-block king-block-bordered king-block-themed m20">
    <div class="king-block-header king-info">
        <ul class="king-block-options">
            <li>
                <!-- <button type="button"><i class="fa fa-cog"></i></button> -->
            </li>
        </ul>
        <h3 class="king-block-title">会议内容录入</h3>        
    </div>
    <div class="king-block-content">
        <form class="form-horizontal">
            <div class="form-group clearfix ">
                <label class="col-sm-3 control-label bk-lh30 pt0">主题：</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control bk-valign-top" id="theme" placeholder="会议主题"> </div>
            </div>
            <div class="form-group has-feedback clearfix ">
                <label class="control-label col-sm-3 pt0" for="introduction">内容：</label>
                <div class="col-sm-9">
                    <textarea class="form-control" rows="3" id="content" placeholder="内容"></textarea>
                </div>
            </div>
            <div class="form-group clearfix">
                <div class="col-sm-9 col-sm-offset-3">
                    <button type="button" class="king-btn mr10  king-success" onclick="save_record(this)">提交</button>
                    {% comment %} <button type="button" class="king-btn king-default ">取消</button> {% endcomment %}
                </div>
            </div>
        </form>
    </div>
</div>
<div class="king-block king-block-bordered king-block-themed m20">
    <div class="king-block-header king-info">
        <ul class="king-block-options">
            <li>
                <!-- <button type="button"><i class="fa fa-cog"></i></button> -->
            </li>
        </ul>
        <h3 class="king-block-title">会议信息展示</h3>
    </div>
    <div class="king-block-content">
        <div style="height:310px; overflow: auto;" id="list_1526104329322" class="king-list3 m0">
            <table class="king-list3-table ranger-box">
                <tbody></tbody>
            </table>
        </div>
        <!-- 设置面板Start -->
        <template id="ranger_nodata_tpl">
            <tr>
                <td colspan="3"> 没有数据 </td>
            </tr>
        </template>
        <template id="ranger_tpl">
            <tr>
                <td style="width:42px;">#index#</td>
                <td style="width:40%;">#theme#</td>
                <td>#content#</td>
                <td style="width:50px;cursor:pointer;color:blue" onclick="delete_record(#theme#)">删除</td>
            </tr>
        </template>
        <!-- 设置面板End -->
    </div>
</div>
     <!-- 尾部声明 start -->
        <!-- jquery js  -->
        <script src="{{ STATIC_URL }}js/jquery-1.10.2.min.js" type="text/javascript"></script>
        <script src="{{ STATIC_URL }}js/jquery.json-2.3.min.js" type="text/javascript"></script>
        <!-- bootstrap js  -->
        <script src="{{ STATIC_URL }}assets/bootstrap-3.3.4/js/bootstrap.min.js" type="text/javascript"></script>
        <script src="{{ STATIC_URL }}assets/echarts-2.0/echarts-all.js"></script>
        <!--配置js  勿删-->
        <script src="{{ STATIC_URL }}js/settings.js?v=${STATIC_VERSION}" type="text/javascript"></script>
        <!-- app使用数据统计上报脚本 -->
        {% comment %} <script src="${BK_PLAT_HOST}/console/static/js/analysis.min.js?v=${STATIC_VERSION}" type="text/javascript"></script> {% endcomment %}
        ${self.body()}
</html>
<script>
    function renderTpl(str, cfg) {
            var re = /(#(.+?)#)/g;

            return str.replace(re, function() {
                var val = cfg[arguments[2]]+'';
                if(typeof val == 'undefined') {
                    val = '';
                }
                return val;
            });
        }

    function initRanger(conf){
        // 异步请求后台数据
        $.ajax({
            url: conf.url,
            type: 'GET',
            dataType: conf.dataType,
            success: function(res){
                //获取数据成功
                if (res.code == 0){
                    var _html = ' ';
                    var list = res.data;
                    
                    var tpl = $('#ranger_tpl').html();
                    if (list.length == 0){
                        _html = $('#ranger_nodata_tpl').html();
                    }else{
                        for (var i=0,len=list.length; i < len; i++){
                            var item = list[i];
                            _html += renderTpl(tpl, item)
                        }
                    }
                    $(conf.container).html(_html);
                }
            }
        });
    }
    
    //保存会议数据
    function save_record(obj){
        var theme = $('#theme').val();
        var content = $('#content').val();
        $.post('{{ SITE_URL }}iwork/save_record/', {'theme': theme, 'content': content}, function(data){
            if(data.result){
                alert(data.message)
                initRanger({
                    url: '{{ SITE_URL }}iwork/records/',
                    dataType: 'json',
                    container: '#list_1526104329322 .ranger-box tbody'
                });
            }else{
                alert(data.message)
            }
        }, 'json')
        return
    }
    
    function delete_record(obj){
         $.post('{{ SITE_URL }}iwork/delete_record/', {'theme': obj}, function(data){
             initRanger({
                    url: '{{ SITE_URL }}iwork/records/',
                    dataType: 'json',
                    container: '#list_1526104329322 .ranger-box tbody'
                });
        }, 'json')
        return
    }
</script>
<script>
    //获取会议记录
    initRanger({
            url: '{{ SITE_URL }}iwork/records/',
            dataType: 'json',
            container: '#list_1526104329322 .ranger-box tbody'
        });
</script>